package com.net;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.List;

public class Server {
    public static void main(String[] args) throws IOException {
        //使用nio来理解阻塞模式
        //1 创建服务器

        ServerSocketChannel ssc  = ServerSocketChannel.open();

        //2绑定端口
        ssc.bind(new InetSocketAddress(8888));

        List<SocketChannel> socketChannelList = new ArrayList<SocketChannel>();
        while (true){
            SocketChannel socketChannel =   ssc.accept();//很多客户端都会调用，多次调用
            socketChannelList.add(socketChannel);
        }

    }
}
